package com.wanmait.computershop.webController;

import com.wanmait.computershop.dao.WebSearchDao;
import com.wanmait.computershop.vo.Product;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("web")
public class WebSearchController {
    @GetMapping("search")
    public String search(String search, Model model){
        model.addAttribute("search",search);
        WebSearchDao webSearchDao = new WebSearchDao();
        List<Product> searchProductList = webSearchDao.findProductsBySearch(search);
        model.addAttribute("searchProductList",searchProductList);
        return "web/product/search";
    }
}
